<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
import {yieldDataDay} from '@/api/yield'
import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)

export default {
  components: {
    Chart,
    yieldDataDay
  },
  data() {
    return {
      cdata: {
        dataList: [],
        dayList: [],
        nightList: [],
        yieldRateList: [],
        category: [
          '12-26',
          '12-27',
          '12-28',
          '12-29',
          '12-30',
          '12-31',
          '01-01',
          '01-02',
          '01-03',
          '01-04',
          '01-05',
          '01-06',
          '01-07',
          '01-08',
          '01-09'
          // "01-10",
          // "01-11",
          // "01-12",
          // "01-13",
          // "01-14",
          // "01-15",
          // "01-16",
          // "01-17",
          // "01-18",
          // "01-19",
          // "01-20",
          // "01-21",
          // "01-22",
          // "01-23",
          // "01-24",
          // "01-25",
        ],
        allData: [
          91.4,
          87.8,
          91.4,
          91.4,
          91.4,
          91.4,
          88.8,
          91.4,
          93,
          88.8,
          91.4,
          92.2,
          91.4,
          95,
          91.4
        ],
        perfectData: [
          90.4,
          89,
          90.4,
          90.9,
          90.4,
          90.4,
          88.5,
          90.4,
          92.3,
          88.5,
          90.4,
          92.2,
          91.7,
          94.4,
          90.4
        ],
        rateData: [
          12609,
          11979,
          12651,
          12543,
          12731,
          12622,
          12179,
          12644,
          12939,
          12179,
          12628,
          12696,
          12609,
          13249,
          12612
        ]
      },
      searchTime: [],
      queryParams: {
        pageNum: 1,
        pageSize: 30
      },
      timing2: null,
      currentData: {},
      currentDataFakeNow: {
        'total': 14,
        'rows': [
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-16 21:01:03',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 180,
            'timeStart': '2024-05-03 09:00',
            'timeEnd': '2024-05-03 20:59',
            'totalOutput': 7496.4465900000005,
            'yieldOutput': 6978.45048,
            'yieldOutputSquare': 23031.5016,
            'yieldOutputQty': 2579,
            'yieldRate': 0.9216967528611446,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9643272586273749,
            'level2Yield': 6662.97144,
            'level3Rate': 0.03567274137262504,
            'level3Yield': 246.47904,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.07830324713885542,
            'wasteYield': 586.99611,
            'waste1Yield': 75.45895,
            'waste1Rate': 0.12855102225464493,
            'waste2Yield': 6.730740000000001,
            'waste2Rate': 0.011466413295311275,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 10.71648,
            'waste4Rate': 0.018256475328260694,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': null,
            'waste6Rate': null,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 15.8112,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 478.27874,
            'waste11Rate': 0.8147903058505788,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-17 09:01:02',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 181,
            'timeStart': '2024-05-03 21:00',
            'timeEnd': '2024-05-04 08:59',
            'totalOutput': 7525.898640000001,
            'yieldOutput': 6930.4936,
            'yieldOutputSquare': 23245.8312,
            'yieldOutputQty': 2603,
            'yieldRate': 0.9266334418769157,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9669611986169805,
            'level2Yield': 6743.34504,
            'level3Rate': 0.033038801383019595,
            'level3Yield': 230.40432,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.07336655812308414,
            'wasteYield': 552.14928,
            'waste1Yield': 45.98753,
            'waste1Rate': 0.08328821872229916,
            'waste2Yield': null,
            'waste2Rate': null,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 8.03736,
            'waste4Rate': 0.014556498199182656,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': null,
            'waste6Rate': null,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 17.1288,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 480.99559,
            'waste11Rate': 0.8711332377359978,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-17 21:01:03',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 182,
            'timeStart': '2024-05-04 09:00',
            'timeEnd': '2024-05-04 20:59',
            'totalOutput': 5582.892139999999,
            'yieldOutput': 6970.629399999999,
            'yieldOutputSquare': 16252.098,
            'yieldOutputQty': 1968,
            'yieldRate': 0.8733160658912532,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9026858440061093,
            'level2Yield': 4401.161639999999,
            'level3Rate': 0.09731415599389077,
            'level3Yield': 474.46776,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.12668393410874676,
            'wasteYield': 707.26274,
            'waste1Yield': 146.58336,
            'waste1Rate': 0.20725446387858634,
            'waste2Yield': 42.352199999999996,
            'waste2Rate': 0.05988184815165012,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 87.09336,
            'waste4Rate': 0.12314145094084838,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': null,
            'waste6Rate': null,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 27.5832,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 403.65062,
            'waste11Rate': 0.5707223032843495,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-18 09:01:02',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 183,
            'timeStart': '2024-05-04 21:00',
            'timeEnd': '2024-05-05 08:59',
            'totalOutput': 7455.558709999999,
            'yieldOutput': 6978.4076,
            'yieldOutputSquare': 22714.692,
            'yieldOutputQty': 2821,
            'yieldRate': 0.9140036132852074,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9485997873094648,
            'level2Yield': 6464.1456,
            'level3Rate': 0.051400212690535275,
            'level3Yield': 350.262,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.08599638671479258,
            'wasteYield': 641.15111,
            'waste1Yield': 99.11682,
            'waste1Rate': 0.1545919806642774,
            'waste2Yield': 15.681600000000001,
            'waste2Rate': 0.024458508696959133,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 31.4028,
            'waste4Rate': 0.04897878130476917,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': null,
            'waste6Rate': null,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 20.196,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 474.75389,
            'waste11Rate': 0.7404711348000318,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-18 21:01:04',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 184,
            'timeStart': '2024-05-05 09:00',
            'timeEnd': '2024-05-05 20:59',
            'totalOutput': 7439.669129999999,
            'yieldOutput': 6880.78392,
            'yieldOutputSquare': 26860.3128,
            'yieldOutputQty': 3364,
            'yieldRate': 0.886569524093876,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9495427861135876,
            'level2Yield': 6262.97904,
            'level3Rate': 0.050457213886412465,
            'level3Yield': 332.80488,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.11343047590612407,
            'wasteYield': 843.8852099999999,
            'waste1Yield': 17.02782,
            'waste1Rate': 0.020177886516105668,
            'waste2Yield': 161.39108,
            'waste2Rate': 0.19124766981044733,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 151.14239999999998,
            'waste4Rate': 0.1791030322714152,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 4.8312,
            'waste6Rate': 0.005724949249910424,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 17.1558,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 492.33691,
            'waste11Rate': 0.5834169199386727,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-19 09:01:03',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 185,
            'timeStart': '2024-05-05 21:00',
            'timeEnd': '2024-05-06 08:59',
            'totalOutput': 7475.826189999999,
            'yieldOutput': 6919.0,
            'yieldOutputSquare': 33045.45165,
            'yieldOutputQty': 4147,
            'yieldRate': 0.8840615287231551,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9187834023748318,
            'level2Yield': 6072.322499999999,
            'level3Rate': 0.0812165976251682,
            'level3Yield': 536.76783,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.11593847127684492,
            'wasteYield': 866.7358599999999,
            'waste1Yield': 136.01942,
            'waste1Rate': 0.15693295532966642,
            'waste2Yield': 82.07284,
            'waste2Rate': 0.09469187071595261,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 81.16617000000001,
            'waste4Rate': 0.09364579654059775,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 1.59401,
            'waste6Rate': 0.0018390954771387907,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 15.190000000000001,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 550.69342,
            'waste11Rate': 0.6353647580705846,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-19 21:01:04',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 186,
            'timeStart': '2024-05-06 09:00',
            'timeEnd': '2024-05-06 20:59',
            'totalOutput': 7485.46697,
            'yieldOutput': 6944.482999999999,
            'yieldOutputSquare': 32372.414999999997,
            'yieldOutputQty': 4533,
            'yieldRate': 0.8649404273571992,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9463534864482617,
            'level2Yield': 6127.14956,
            'level3Rate': 0.0535163873316217,
            'level3Yield': 346.49094,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.13505957264280063,
            'wasteYield': 1010.9839699999999,
            'waste1Yield': 77.29838,
            'waste1Rate': 0.076458561454738,
            'waste2Yield': 68.90698,
            'waste2Rate': 0.06815833093772991,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 242.45573000000002,
            'waste4Rate': 0.23982153742754206,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 2.95256,
            'waste6Rate': 0.00292048151861399,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 28.23125,
            'waste9Rate': 0.0,
            'waste10Yield': 1.66125,
            'waste10Rate': 0.0016432011281049294,
            'waste11Yield': 589.47782,
            'waste11Rate': 0.5830733597091554,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-20 09:01:02',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 187,
            'timeStart': '2024-05-06 21:00',
            'timeEnd': '2024-05-07 08:59',
            'totalOutput': 7458.366539999999,
            'yieldOutput': 6823.0,
            'yieldOutputSquare': 33400.1991,
            'yieldOutputQty': 4164,
            'yieldRate': 0.8956438094285456,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9384294269072186,
            'level2Yield': 6268.74594,
            'level3Rate': 0.061570573092781355,
            'level3Yield': 411.29388,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.10435619057145455,
            'wasteYield': 778.32672,
            'waste1Yield': 82.14292999999999,
            'waste1Rate': 0.10553785176487322,
            'waste2Yield': 20.9352,
            'waste2Rate': 0.02689770177747463,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 123.57824999999998,
            'waste4Rate': 0.15877426127680672,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': null,
            'waste6Rate': null,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 15.67625,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 535.99409,
            'waste11Rate': 0.6886492217561283,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-20 21:01:04',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 188,
            'timeStart': '2024-05-07 09:00',
            'timeEnd': '2024-05-07 20:59',
            'totalOutput': 7460.842380000001,
            'yieldOutput': 6930.21519,
            'yieldOutputSquare': 37156.746999999996,
            'yieldOutputQty': 6463,
            'yieldRate': 0.8406845863429163,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9544740396574307,
            'level2Yield': 5986.666569999999,
            'level3Rate': 0.045525960342569186,
            'level3Yield': 285.54862,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.15931541365708363,
            'wasteYield': 1188.6271900000004,
            'waste1Yield': 100.47212,
            'waste1Rate': 0.08452786613437639,
            'waste2Yield': 195.25185,
            'waste2Rate': 0.1642666865125304,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 363.27787,
            'waste4Rate': 0.3056281002624548,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 21.740399999999998,
            'waste6Rate': 0.01829034383775117,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 8.39022,
            'waste9Rate': 0.0,
            'waste10Yield': 6.006,
            'waste10Rate': 0.005052887945462528,
            'waste11Yield': 493.48873,
            'waste11Rate': 0.41517536713929604,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-21 09:01:03',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 189,
            'timeStart': '2024-05-07 21:00',
            'timeEnd': '2024-05-08 08:59',
            'totalOutput': 7502.267769999998,
            'yieldOutput': 6936.0,
            'yieldOutputSquare': 41846.0,
            'yieldOutputQty': 8575,
            'yieldRate': 0.9203337193068492,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.9675801749271138,
            'level2Yield': 6680.7444,
            'level3Rate': 0.0324198250728863,
            'level3Yield': 223.8456,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.07966628069315101,
            'wasteYield': 597.6777699999999,
            'waste1Yield': 67.6368,
            'waste1Rate': 0.1131659957839824,
            'waste2Yield': 6.6,
            'waste2Rate': 0.011042739635439345,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 20.13,
            'waste4Rate': 0.03368035588809,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 5.6364,
            'waste6Rate': 0.009430499648665202,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': null,
            'waste9Rate': null,
            'waste10Yield': 16.302,
            'waste10Rate': 0.027275566899535184,
            'waste11Yield': 481.37257,
            'waste11Rate': 0.805404842144288,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-21 21:01:03',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 190,
            'timeStart': '2024-05-08 09:00',
            'timeEnd': '2024-05-08 20:59',
            'totalOutput': 7517.3723199999995,
            'yieldOutput': 6763.0,
            'yieldOutputSquare': 40699.2,
            'yieldOutputQty': 8340,
            'yieldRate': 0.8933132102734538,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.8929256594724221,
            'level2Yield': 5996.3244,
            'level3Rate': 0.10707434052757793,
            'level3Yield': 719.0436,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.10668678972654635,
            'wasteYield': 802.0043199999999,
            'waste1Yield': 216.5988,
            'waste1Rate': 0.27007186195705285,
            'waste2Yield': 14.127960000000002,
            'waste2Rate': 0.017615815336256547,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 61.1952,
            'waste4Rate': 0.07630283088749448,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 3.2208,
            'waste6Rate': 0.004015938467762868,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': null,
            'waste9Rate': null,
            'waste10Yield': 24.882,
            'waste10Rate': 0.031024770539889366,
            'waste11Yield': 481.97956,
            'waste11Rate': 0.600968782811544,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-22 09:01:04',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 191,
            'timeStart': '2024-05-08 21:00',
            'timeEnd': '2024-05-09 08:59',
            'totalOutput': 7467.006779999999,
            'yieldOutput': 6936.0,
            'yieldOutputSquare': 38586.88,
            'yieldOutputQty': 8720,
            'yieldRate': 0.8526623033279207,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.7403552710143966,
            'level2Yield': 4713.719999999999,
            'level3Rate': 0.2596447289856034,
            'level3Yield': 1653.1152,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.14733769667207935,
            'wasteYield': 1100.1715799999997,
            'waste1Yield': 365.9568,
            'waste1Rate': 0.33263611481401845,
            'waste2Yield': 103.03062,
            'waste2Rate': 0.09364959236631074,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 114.7212,
            'waste4Rate': 0.104275734881281,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 2.178,
            'waste6Rate': 0.001979691204166536,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': null,
            'waste9Rate': null,
            'waste10Yield': 35.178,
            'waste10Rate': 0.03197501247941708,
            'waste11Yield': 479.10696,
            'waste11Rate': 0.43548385425480646,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-22 21:01:04',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 192,
            'timeStart': '2024-05-09 09:00',
            'timeEnd': '2024-05-09 20:59',
            'totalOutput': 7276.627349999998,
            'yieldOutput': 6947.0,
            'yieldOutputSquare': 29215.894400000005,
            'yieldOutputQty': 3514,
            'yieldRate': 0.7923747957218121,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.6979064651439257,
            'level2Yield': 4024.00034,
            'level3Rate': 0.3020935348560744,
            'level3Yield': 1741.81577,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.20762520427818806,
            'wasteYield': 1510.8112399999998,
            'waste1Yield': 640.67752,
            'waste1Rate': 0.424061923182409,
            'waste2Yield': 56.90385,
            'waste2Rate': 0.037664433844164416,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 236.92884999999998,
            'waste4Rate': 0.15682227119252834,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': 8.050550000000001,
            'waste6Rate': 0.005328627287681552,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 37.30272,
            'waste9Rate': 0.0,
            'waste10Yield': 7.722,
            'waste10Rate': 0.005111161338725545,
            'waste11Yield': 523.22575,
            'waste11Rate': 0.34632105993598516,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': '2024-04-23 09:01:02',
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'id': 193,
            'timeStart': '2024-05-09 21:00',
            'timeEnd': '2024-05-10 08:59',
            'totalOutput': 7398.33586,
            'yieldOutput': 6949.43713,
            'yieldOutputSquare': 31685.0592,
            'yieldOutputQty': 3548,
            'yieldRate': 0.8779592131141772,
            'level1Rate': null,
            'level1Yield': null,
            'level2Rate': 0.809188275524114,
            'level2Yield': 5256.03157,
            'level3Rate': 0.190811724475886,
            'level3Yield': 1239.40556,
            'level4Rate': null,
            'level4Yield': null,
            'wasteRate': 0.12204078688582272,
            'wasteYield': 902.89873,
            'waste1Yield': 407.37013,
            'waste1Rate': 0.45118031121829133,
            'waste2Yield': null,
            'waste2Rate': null,
            'waste3Yield': null,
            'waste3Rate': null,
            'waste4Yield': 18.30732,
            'waste4Rate': 0.02027616098208489,
            'waste5Yield': null,
            'waste5Rate': null,
            'waste6Yield': null,
            'waste6Rate': null,
            'waste7Yield': null,
            'waste7Rate': null,
            'waste8Yield': null,
            'waste8Rate': null,
            'waste9Yield': 19.5078,
            'waste9Rate': 0.0,
            'waste10Yield': null,
            'waste10Rate': null,
            'waste11Yield': 457.71348,
            'waste11Rate': 0.5069377824908448,
            'waste12Yield': null,
            'waste12Rate': null,
            'waste0Yield': null,
            'waste0Rate': null,
            'bz1': null,
            'bz2': null,
            'bz3': null,
            'bz4': null,
            'bz5': null
          }
        ],
        'code': 200,
        'msg': '查询成功'
      },
      currentDataFake: {
        'msg': '操作成功',
        'code': 200,
        'data': [
          {
            'searchValue': null,
            'createBy': null,
            'createTime': null,
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'beginTime': '2024-01-18 09:00',
            'endTime': '2024-01-18 20:59',
            'yield': 3673.3224,
            'firstLevelYield': 0.0,
            'secondLevelYield': 0.0,
            'thirdLevelYield': 3673.3224,
            'wasteYield': 290.48824,
            'yieldRate': 0.9267149048270379,
            'total': 3963.8106399999997
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': null,
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'beginTime': '2024-01-19 09:00',
            'endTime': '2024-01-19 20:59',
            'yield': 6211.6956,
            'firstLevelYield': 0.0,
            'secondLevelYield': 0.0,
            'thirdLevelYield': 6211.6956,
            'wasteYield': 525.3076100000001,
            'yieldRate': 0.922026516297296,
            'total': 6737.003209999999
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': null,
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'beginTime': '2024-01-18 21:00',
            'endTime': '2024-01-19 08:59',
            'yield': 6237.8844,
            'firstLevelYield': 0.0,
            'secondLevelYield': 0.0,
            'thirdLevelYield': 6237.8844,
            'wasteYield': 500.1673,
            'yieldRate': 0.9257697443906523,
            'total': 6738.0517
          },
          {
            'searchValue': null,
            'createBy': null,
            'createTime': null,
            'updateBy': null,
            'updateTime': null,
            'remark': null,
            'params': {},
            'beginTime': '2024-01-19 21:00',
            'endTime': '2024-01-20 08:59',
            'yield': 6239.244,
            'firstLevelYield': 0.0,
            'secondLevelYield': 0.0,
            'thirdLevelYield': 6239.244,
            'wasteYield': 492.68613999999997,
            'yieldRate': 0.9268135393930276,
            'total': 6731.93014
          }
        ]
      }
    }
  },
  mounted() {
    // this.setData();
    // this.getYieldDataDay(); // todo base
    //   this.timeFn2(); // todo base
  },
  beforeDestroy() {
    clearInterval(this.timing2)
  },
  methods: {
    setData() { },
    // 当班不查 查上一班
    // currentData => lastMonth 26Day
    getYieldDataDay() {
      // this.getSearchTime();
      // currentDataFakeNow 格式化灌入 filterData 用dataCombine组装进cdata
      // this.getDealTime();
      // http://localhost/dev-api/mes/pro/yield/yieldStaticsByDay?pageNum=1&pageSize=30&params%5BbeginTime%5D=20240108085900&params%5BendTime%5D=20240108090100
      const currentTime = dayjs(new Date()).format('YYYYMMDDHHmmss')
      const last7day = this.getMorningTime()
      this.searchTime = [last7day, currentTime]
      // 本地时间
      // this.searchTime = ["20240117085900", currentTime];
      yieldDataDay(this.addDateRange(this.queryParams, this.searchTime)).then(response => {
        this.currentData = response.rows
        this.currentDataFakeNow = response // todo 测试后取消注释
        // console.log("!!!currentData!!!", this.currentData)
      }).then(this.getDealTime)
    },
    formatDataNow(data) {
      return {
        // 班组起始时间
        beginTime: data.timeStart,
        // 班组时间戳 排序用
        classTimeValue: dayjs(data.timeStart).valueOf(),
        // 班组时间
        classTime: dayjs(data.timeStart).format('MM-DD'),
        // 班组类别 早班 晚班
        classType: (dayjs(data.timeStart).format('HH') === '09') ? ('早班') : ('晚班'),
        // 班组产量
        yield: data.yieldOutput,
        // 班组成品率
        yieldRate: data.yieldRate,
        // 理论成品率
        theoryRate: data.yieldOutput / data.totalOutput,
        // 班组总量
        total: data.totalOutput,
        // 班组高等品产量
        hightYield: data.totalOutput,
        // 班组普通品产量
        normalYield: data.totalOutput
      }
    },
    formatData(data) {
      return {
        // 班组起始时间
        beginTime: data.beginTime,
        // 班组时间戳 排序用
        classTimeValue: dayjs(data.beginTime).valueOf(),
        // 班组时间
        classTime: dayjs(data.beginTime).format('MM-DD'),
        // 班组类别 早班 晚班
        classType: (dayjs(data.beginTime).format('HH') === '09') ? ('早班') : ('晚班'),
        // 班组产量
        yield: data.yield,
        // 班组成品率
        yieldRate: data.yieldRate,
        // 理论成品率
        theoryRate: data.yield / data.total,
        // 班组总量
        total: data.total
      }
    },
    dataCombine(arr) {
      //  1 生成日期组 ["01-18","01-19"]
      const dateArr = arr.reduce(function(acc, cur) {
        const found = acc.find(item => item.classTime === cur.classTime)
        if (!found) {
          acc.push({classTime: cur.classTime, classTimeValue: cur.classTimeValue})
        }
        return acc
      }, [])
      //  2 日期排序 升序
      const dataList = dateArr.sort(function(a, b) {
        return a['classTimeValue'] - b['classTimeValue']
      }).map(item => item.classTime)
      //  2.1 提前日期全数组排序 升序
      const arrList = arr.sort(function(a, b) {
        return a['classTimeValue'] - b['classTimeValue']
      })
      // [{classTime:"01-18"}, {classType:"晚班"}] => 当日总产品率计算
      // 3 按日期排序计算日总产量、日总量及日成品率
      const arrData = arr.reduce(function(acc, cur) {
        const foundAgain = acc.find(item => item.classTime === cur.classTime)
        const resultArray = {
          classType: cur.classType,
          data:
                      [{
                        yield: cur.yield,
                        total: cur.total
                      }]
        }
        if (foundAgain) {
          const foundClass = foundAgain.data.find(item => item.data.classType === cur.classType)
          if (foundClass) {
            console.log('重复数据', foundClass, cur)
          } else {
            foundAgain.data.push(resultArray)
            foundAgain.yieldDay += cur.yield
            foundAgain.totalDay += cur.total
            foundAgain.yieldRateDay = foundAgain.yieldDay / foundAgain.totalDay
          }
          // yieldTotal
        } else {
          // console.log("初始计算", cur.yield / cur.total);
          acc.push({
            classTime: cur.classTime,
            yieldRateDay: cur.yield / cur.total,
            yieldDay: cur.yield,
            totalDay: cur.total,
            data: [resultArray]
          })
        }
        return acc
      }, [])
      // 3.1 按日期排序计算日总产量、日总量及日成品率
      const arrDataList = arrList.reduce(function(acc, cur) {
        const foundAgain = acc.find(item => item.classTime === cur.classTime)
        const resultArray = {
          classType: cur.classType,
          data:
                      [{
                        yield: cur.yield,
                        total: cur.total
                      }]
        }
        if (foundAgain) {
          const foundClass = foundAgain.data.find(item => item.data.classType === cur.classType)
          if (foundClass) {
            console.log('重复数据', foundClass, cur)
          } else {
            foundAgain.data.push(resultArray)
            foundAgain.yieldDay += cur.yield
            foundAgain.totalDay += cur.total
            foundAgain.yieldRateDay = foundAgain.yieldDay / foundAgain.totalDay
          }
          // yieldTotal
        } else {
          // console.log("初始计算", cur.yield / cur.total);
          acc.push({
            classTime: cur.classTime,
            yieldRateDay: cur.yield / cur.total,
            yieldDay: cur.yield,
            totalDay: cur.total,
            data: [resultArray]
          })
        }
        return acc
      }, [])
      console.log('排序组装arrDataList', arrDataList)
      // 日期数组 早班产量数组 晚班产量数组 单日成品率数组
      // 早班数组测试
      // let dayList = arrDataList.filter(item => item.data[0].classType === "早班");
      const dayList = arrDataList.map(item => this.dayOrNightValue(item.data, '早班'))
      const nightList = arrDataList.map(item => this.dayOrNightValue(item.data, '晚班'))
      const yieldRateList = arrDataList.map(item => item.yieldDay)
      // let yieldRateList = arrDataList.map(item => (item.yieldRateDay)*10000);
      // let nightList = arrDataList.map(item => (item.data[0].classType === "早班")?(item.data[0].data[0].yield):0);
      this.cdata = {
        dataList: dataList,
        dayList: dayList,
        nightList: nightList,
        yieldRateList: yieldRateList
      }
      return {'dataList': dataList, 'dayList': dayList, 'nightList': nightList, 'yieldRateList': yieldRateList, 'arrDataList': arrDataList}
    },
    // 早晚班判断取值
    dayOrNightValue(dataArr, classType) {
      let thisValue = 0
      for (let i = 0; i < dataArr.length; i++) {
        if (dataArr[i].classType === classType) {
          thisValue = dataArr[i].data[0].yield
        }
      }
      return thisValue
    },
    getDate(hours) {
      const currentDate = new Date()
      const currentYear = currentDate.getFullYear()
      const currentMonth = currentDate.getMonth()
      const currentDay = currentDate.getDate()
      const timeStamp = new Date(
        currentYear,
        currentMonth,
        currentDay,
        0,
        0,
        0
      ).getTime()
      console.log('hours:', hours, 'timeStamp:', timeStamp, 'currentYear:', currentYear, 'currentMonth:', currentMonth, 'currentDay:', currentDay)
      return new Date(timeStamp + hours * 60 * 60 * 1000).getTime()
    },
    getSearchTime() {
      const currentTime = new Date()
      const dateFormatString = 'YYYYMMDDHHmmss'
      // currentYear 2024
      const currentYear = currentTime.getFullYear()
      // currentMonth 0-11
      const currentMonth = currentTime.getMonth()
      // currentDay 1-31
      const currentDay = currentTime.getDate()
      // currentTimeHour 0-23
      const currentTimeHour = currentTime.getHours()

      // 20240104090000
      const beginTime = ''
      // 20240109090000
      let thisEndTime = ''

      // 测试代码
      // const testTime = dayjs("2024-01-09 00:59", 'YYYY-MM-DD HH:mm').format('H')
      // currentTimeHour = Number(testTime)
      // console.log("testTime:",testTime,"currentTimeHour:",currentTimeHour);

      // am 早班 9:00-20:59 pm 21:00-8:59
      let formateTimeRange = ''
      if (currentTimeHour !== undefined) {
        if ((currentTimeHour >= 9) && (currentTimeHour < 21)) {
          // 当日早班情况 查询终止时间是上一个晚班起始时间分界线之后
          formateTimeRange = '210100' // 085900
          // 早班时间一定和分界线是隔天 日期回拨1天
          // 测试时间 2024-01-09 20:59 thisEndTime 20240108210100
          const lastDayTime = dayjs(currentTime).subtract(1, 'day')
          thisEndTime = lastDayTime.format('YYYYMMDD') + formateTimeRange
          console.log('早班时间,一定过0点')
          console.log('现在是早班,返回上一晚班结束时间 ')
        } else {
          // 当日晚班情况 查询终止时间是当前晚班起始时间分界线之前
          formateTimeRange = '205959'
          if (currentTimeHour >= 21) {
            // 晚班时间未过0点 分界线是当天 查当前晚班起始时间之前
            // 测试时间 2024-01-09 23:59 thisEndTime 20240109205959
            thisEndTime = dayjs(currentTime).format('YYYYMMDD') + formateTimeRange
            console.log('过0点')
          } else {
            // 晚班时间过0点 分界线是隔天 日期需要回拨1天
            // 测试时间 2024-01-09 00:59 thisEndTime 20240108205959
            const lastDayTime = dayjs(currentTime).subtract(1, 'day')
            thisEndTime = lastDayTime.format('YYYYMMDD') + formateTimeRange
            console.log('未过0点', lastDayTime.format('YYYYMMDD'), formateTimeRange)
          }
          console.log('现在是晚班,返回上一早班结束时间')
        }
      }
      // 起始月判断 未完成
      //   当月日期<=25 需要回拨1个月
      const formateMonthRange = ''
      if (currentMonth) {
        if (currentMonth === 0) {
          // 1月显示0 26日之前 起始月12月
          // formateTimeRange = '205900'
          // console.log("现在是早班");
        } else {
          // formateTimeRange = '085900'
          // console.log("现在是晚班");
        }
      }
      // console.log("currentTime:", currentTime, "currentYear:", currentYear);
      // console.log("thisEndTime:", thisEndTime);
      // console.log("currentMonth:", currentMonth, "currentDay:", currentDay, "currentTimeHour:", currentTimeHour);
    },
    getMorningTime() {
      const currentTime = new Date()
      const last7day = dayjs(currentTime).subtract(7, 'day')
      let thatMorningStart = ''
      const thatTimeHour = currentTime.getHours()
      const formatTimeRange = '085900'
      if (thatTimeHour !== undefined) {
        if ((thatTimeHour >= 0) && (thatTimeHour < 21)) {
          thatMorningStart = last7day.format('YYYYMMDD') + formatTimeRange
        } else {
          thatMorningStart = last7day.add(1, 'day').format('YYYYMMDD') + formatTimeRange
          // if (thatTimeHour > 21) {
          // }
        }
      }
      // dayjs(new Date()).subtract(6, 'day').format('YYYYMMDD090100')
      return thatMorningStart
    },
    getDealTime() {
      const beginTime = '2024-01-18 21:00'
      const yieldRate = 0.926714904
      // this.searchTime = ["20240117085900", "20240119085900"];
      // this.currentDataFake => 日期数组 早班产量数组 晚班产量数组 单日成品率数组
      const filterData = []
      // for (let i = 0 ; i<this.currentDataFake.data.length; i++) {
      //     filterData.push(this.formatData(this.currentDataFake.data[i]))
      // }
      // filterData = []
      console.log('日计条数:', this.currentDataFakeNow.rows)
      for (let i = 0; i < this.currentDataFakeNow.rows.length; i++) {
        filterData.push(this.formatDataNow(this.currentDataFakeNow.rows[i]))
      }
      // "2024-01-18 09:00" => ["01-18", "早班"]
      // "2024-01-18 21:00" => ["01-18", "晚班"]
      // xAxis.data => ["12-26", "12-27"]
      // 当日总产品率计算 产1+2 除 总1+2  yield(1+2) total(1+2)
      // total && total != 0
      // series[{name: '早班',data:[150, 132]},{name: '晚班',data:[150, 132]},{name: "总成品率",data:[150, 132]}] => ["12-26", "12-27"]
      const testData = []
      // console.log("filterData",filterData);
      if (filterData.length > 0) {
        console.log('filterData 有', filterData, 'dataCombine', this.dataCombine(filterData))
      } else {
        console.log('filterData 没有', filterData)
      }
    },
    timeFn2() {
      this.timing2 = setInterval(() => {
        console.log('t30 left 实时', dayjs(new Date()).format('YYYYMMDDHHmmss'))
        this.getYieldDataDay()
        // todo last6min 刷新间隔
      }, 1800000)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
